<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="/js/jquery-1.12.4.js"></script>
</head>

<body>
    <table border="1">
        <tr>
            <th><input type="checkbox" id="checkAll" /></th>
            <th>姓名</th>
            <th>年龄</th>
        </tr>
        <tr>
            <td><input type="checkbox" class="item" /></td>
            <td>张三</td>
            <td>25</td>
        </tr>
        <tr>
            <td><input type="checkbox" class="item" /></td>
            <td>李四</td>
            <td>30</td>
        </tr>
        <tr>
            <td><input type="checkbox" class="item" /></td>
            <td>王五</td>
            <td>28</td>
        </tr>
    </table>
    <script>
        $(document).ready(function () {
            $('#checkAll').change(function () {
                var isChecked = $(this).prop('checked');
                $('.item').prop('checked', isChecked);
            });
        });
    </script>
</body>

</html>